﻿using Coldairarrow.Business;
using Coldairarrow.Entity;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers
{
    [Route("/Comment/[controller]/[action]")]
    public class Order_MasterController : BaseApiController
    {
        #region DI

        public Order_MasterController(IOrder_MasterBusiness order_MasterBus)
        {
            _order_MasterBus = order_MasterBus;
        }

        private IOrder_MasterBusiness _order_MasterBus { get; }

        #endregion DI

        #region 获取

        [HttpPost]
        public async Task<PageResult<Order_Master>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _order_MasterBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Order_Master> GetTheData(IdInputDTO input)
        {
            return await _order_MasterBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 后台获取订单
        /// </summary>
        /// <param name="order_"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Order_Dto>> GetDataTwo(PageInput<Order_DtoTwo> order_)
        {
            return await _order_MasterBus.GetOrderDataTwo(order_);
        }

        /// <summary>
        /// 后台获取订单详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Order_Dto> GetOrderTheDataTwo(string Id)
        {
            return await _order_MasterBus.GetOrderTheDataTwo(Id);
        }

        /// <summary>
        /// 后台获取统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public orderStatistics getStatistics()
        {
            return  _order_MasterBus.getStatistics();
        }
        #endregion 获取

        #region 提交

        [HttpPost]
        public async Task SaveData(Order_Master data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _order_MasterBus.AddDataAsync(data);
            }
            else
            {
                await _order_MasterBus.UpdateDataAsync(data);
            }
        }

        /// <summary>
        /// 前台——删除个人订单号
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DelData(List<string> ids)
        {
            await _order_MasterBus.DelDataAsync(ids);
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _order_MasterBus.DeleteDataAsync(ids);
        }

        #endregion 提交
    }
}